package ca.seia.comp6521.a2.util;

public class NumberUtil {

	public static int parseInt( final String s )
	{
	    // Check for a sign.
//	    int num  = 0;
//	    int sign = -1;
//	    final int len  = s.length( );
//	    final char ch  = s.charAt( 0 );
//	    if ( ch == '-' )
//	        sign = 1;
//	    else
//	        num = '0' - ch;
		int sign = -1;
		final int len  = s.length( );
		int num  = 0;
	    num = '0' - s.charAt( 0 );
	    
	    // Build the number.
	    int i = 1;
	    while ( i < len )
	        num = num*10 + '0' - s.charAt( i++ );

	    return  sign*num;
	} 
}
